$(function(){

    // shuffle.js config 
    $(document).ready(function() {

        /* initialize shuffle plugin */
        var $grid = $('#grid');
        var $sizer = $('.shuffle-sizer');
        
        $grid.shuffle({
            itemSelector: '.item', 
            sizer: $sizer,
            group: 'all', 
            speed: 300, 
            easing: 'ease-out', 
            gutterWidth: 0
            //columnWidth: 350
        });

        /* reshuffle when user clicks a filter item */
        $('#filter a').click(function (e) {
            e.preventDefault();

            // set active class
            $('#filter a').removeClass('active');
            $(this).addClass('active');

            // get group name from clicked item
            var groupName = $(this).attr('data-group');

            // reshuffle grid
            $grid.shuffle('shuffle', groupName );
        });

    });
    
    // menu toggle
    $('#search-icon, #logo, #menu-icon').on('click',function() {
        $('#top-nav-menu').animate({right: '0px'}, 200);
    });
        
    $('#top-nav-menu a').on('click', function(e) {
		e.preventDefault();
		var target = $(this).attr('href');
        $('#top-nav-menu').animate({right: '-310px'}, 200, function(){
			window.location.href = target;
		});
    });
    
    $('#close-button').on('click', function() {
        $('#top-nav-menu').animate({right: '-310px'}, 200);
    });
    
    // animations on scroll
    $(window).scroll(function(){
        $('#content-home').animate({top : '100px'}, 1000);
    });
    
    $('#content-home').css('margin-top', ($(window).height()+50) + 'px');  
    
    $(window).on('resize', function(){
        $('#content-home').css('margin-top', ($(window).height()+50) + 'px');
        
    });
          
    $(document).one('scroll', function() {
 
 
        if ($(window).scrollTop() >= 1) {
            
            $('#scroll-icon').hide();
            
            $('#content-home').animate({'margin-top':100,'opacity':1},1000,function(){
                // show header
                $('#header').animate({opacity: "1"}, 200);

            });       
        } else {
            //$('#content-home').animate({'margin-top':($(window).height()+50),'opacity':1},2000);
        }
    });
    
    // positioning of elements relative to height of window or document
    var screenBotton = $(window).height() - 100;
    var documentHeight = $(document).height();
    $('#scroll-icon').css('top' ,  screenBotton);
    
    // pretty photo config
    $("a[rel^='prettyPhoto']").prettyPhoto({
			animation_speed: 'fast', /* fast/slow/normal */
			slideshow: 5000, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 0.80, /* Value between 0 and 1 */
			show_title: true, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
			default_width: 500,
			default_height: 344,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			horizontal_padding: 20, /* The padding on each side of the picture */
			modal: false, /* If set to true, only the close button will close the window */
			deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */
			overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
			ie6_fallback: true
		});
}());



